package cn.topevery.garden.dal.logic;

import cn.topevery.garden.dal.dao.DiseaseDao;
import cn.topevery.garden.entity.po.Disease;
import cn.topevery.garden.entity.query.DiseaseQuery;
import cn.topevery.garden.entity.vo.DiseaseVO;
import cn.topevery.garden.framework.base.BaseLogic;
import hw.topevery.framework.db.base.BaseEntityDao;
import hw.topevery.framework.db.entity.DataPager;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 病虫害表
 *
 * @author code-generate
 * @date 2022-01-05
 */
@Service
public class DiseaseLogic extends BaseLogic<Disease> {
    @Autowired
    DiseaseDao diseaseDao;

    @Override
    public BaseEntityDao<Disease, Integer> getDao() {
        return diseaseDao;
    }


    /**
     * 获取列表
     *
     * @param query
     */
    public DataPager<DiseaseVO> listPage(DiseaseQuery query) {
        return diseaseDao.listPage(query);
    }

    /**
     * 根据自增id批量删除
     *
     * @param ids
     */
    public void deleteBatchById(String userId, Integer[] ids) {
        diseaseDao.delete(userId, ids);
    }

    /**
     * 根据自增id保存或者更新
     *
     * @param disease 实体
     */
    public void saveOrUpdate(String userId, Disease disease) {
        diseaseDao.saveOrUpdate(userId, disease);
    }

    /**
     * 根据自定义列值来获取对象
     */
    public Disease getEntityByColumn(String key, String value) {
        return diseaseDao.getEntityByColumn(key, value);
    }

    public DataPager<DiseaseVO> getList(DiseaseQuery query) {
        return diseaseDao.getList(query);
    }

    public void update(Disease disease, Integer userId) {
        diseaseDao.update(disease, userId);
    }

    public void insert(Disease disease, Integer userId) {
        diseaseDao.insert(disease, userId);
    }

    public void deleteByIds(List<String> ids, List<String> months) {
        diseaseDao.deleteByIds(ids, months);
    }

    public Disease getByIdAndMonth(Integer id) {
        return diseaseDao.getByIdAndMonth(id);
    }

}
